/**
 * LispFileReader.java
 *
 * Fecha de creación: Mar 12, 2012,1:05:06 PM
 *
 * Autor: José Ignacio Rivero Dávila
 */

package util;

import java.io.File;
import java.util.LinkedList;
import java.util.Scanner;


public class LispFileReader {
    private final static String PATH = "input.txt";

    public LispFileReader() {
    }
    public LinkedList<Movement> readFile(){
        File f = new File(PATH);
        LinkedList<Movement> listOfMovements = new LinkedList<Movement>();
        int movementCode;
        try{
            Scanner s = new Scanner(f);
            while(s.hasNextInt()){
                movementCode = s.nextInt();
                switch (movementCode){
                    case 0: break;
                    case 1: listOfMovements.add(Movement.UP); break;
                    case 2: listOfMovements.add(Movement.RIGHT); break;
                    case 3: listOfMovements.add(Movement.DOWN); break;
                    case 4: listOfMovements.add(Movement.LEFT); break;
                    default: throw new ErrorInFileException();
                } 
            }
            
        }catch (Exception ex){
            System.err.println(ex);
        }
        return listOfMovements;
    }
    public static void main(String[] args) {
        LispFileReader prueba = new LispFileReader();
        System.out.println(prueba.readFile().toString());
    }

}
